{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "products =   [[“iphone”,6888],[“MacPro”,14800],[“小米6”,2499],[“Coffee”,31],[“Book”,60],[“Nike”,699]]\n",
    "a、打印出以下格式\n",
    "b、\n",
    "购物车功能：\n",
    "根据的products列表写一个循环不断询问用户想买什么，\n",
    "用户选择一个商品编号，就把对应的商品添加到购物车里，\n",
    "最终用户输入q退出时，\n",
    "打印购买的商品列表。\n",
    "提示:有shop_car和shop_cost 两个列表，当时输入商品不存在的时候，提示相关错误"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (<ipython-input-1-ad3caab108da>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-1-ad3caab108da>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m    products =   [[“iphone”,6888],[“MacPro”,14800],[“小米6”,2499],[“Coffee”,31],[“Book”,60],[“Nike”,699]]\u001b[0m\n\u001b[1;37m                          ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "products =   [[“iphone”,6888],[“MacPro”,14800],[“小米6”,2499],[“Coffee”,31],[“Book”,60],[“Nike”,699]]\n",
    "print(\"------商品列表------\")\n",
    "\n",
    "for i in products:\n",
    "    print(i[0],\"\\t \",i[1])\n",
    "    shop_car.append(i[0],i[1],0)\n",
    "    \n",
    "print(\"请选择输入商品名称，退出请输入q\")\n",
    "a = input(\"选择你的商品： \")\n",
    "while a = \"q\"\n",
    "     for i in shop_car:\n",
    "        if a == i[0]:\n",
    "            i[2] += 1\n",
    "            break\n",
    "        else:\n",
    "            print(\"请输入商品有误\")\n",
    "            a = input(\"选择你的商品： \")\n",
    "print(\"------你选择的商品列表------\")\n",
    "    for i in shop_car:\n",
    "        if i[2] > 0:\n",
    "            shop_cost.append(i[1]*i[2])\n",
    "            print(\"{}, {}件,共{}元\".format(i[0],i[2],i[1],i[2]))\n",
    "    print(\"价格总计： \"，sum(shop_cost),\"元\")\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
